// pages/personal/personal.js
const filter = require('../../../utils/filter')
Page(filter.loginCheck({

  /**
   * 页面的初始数据
   */
  data: {
    height: '',
    navList: [{
        name: '发送密语',
        icon: '../../../img/feiji.png',
        url: '../send_secret/send_secret'
      },
      {
        name: '我的任务',
        icon: '../../../img/task.png',
        url: '../my_task/my_task'
      },
      {
        name: '金币充值',
        icon: '../../../img/coin.png',
        url: '../gold_deposits/gold_deposits'
      },
      {
        name: '客户服务',
        icon: '../../../img/service.png',
        url: '../customer_service/customer_service'
      },
      {
        name: '退出登录',
        icon: '../../../img/logout.png',
        url: ''
      },
    ],
    userInfo:{}
  },
  handleNavClick(e) {
    const url = e.currentTarget.dataset.url
    if (!url) {
      this.logout()
      return
    }
    wx.navigateTo({
      url
    })
  },
  logout() {
    wx.removeStorageSync('userInfo')
    wx.redirectTo({
      url: '../../login/login'
    })
  },
  onLoad(options) {
    // 监听窗口高度
    wx.getSystemInfo({
      success: (res) => {
        this.setData({
          height: res.windowHeight
        })
      },
    })
    const userInfo = JSON.parse(wx.getStorageSync('userInfo'))
    this.setData({
      userInfo
    })
  },




  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
}))